package com.base.autoproxy.jdk;

import java.lang.reflect.Proxy;

/**
 * @Author HBZ
 * @Date 2020/11/4 9:15
 * @Description
 */
public class JDKProxyMain {
    public static void main(String[] args) {
        JDKProxyInterface target = new JDKProxyInterfaceImpl();
        // 根据目标对象创建代理对象
        JDKProxyInterface proxy =
                (JDKProxyInterface) Proxy.newProxyInstance(target.getClass().getClassLoader(),
                        target.getClass().getInterfaces(), new JDKProxyInvocationHandler(target));
        // 调用代理对象方法
        proxy.testProxy();
        System.out.println(proxy.getClass());
    }
}
